import 'package:flutter/material.dart';

class Contact extends StatefulWidget {
  const Contact({super.key});

  @override
  State<Contact> createState() => _ContactState();
}

class _ContactState extends State<Contact> {
  List<Map<String, String>> defItems = [
    {"img": "assets/images/contact_new_friend.jpg", "title": "新的朋友"},
    {"img": "assets/images/contact_official.jpg", "title": "公众号"},
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: const Color(0xffDEDEDE),
        centerTitle: true,
        elevation: 0,
        title: const Text("通讯录",
            style: TextStyle(color: Color(0xff181818), fontSize: 16)),
        actions: [
          InkWell(
              onTap: () {
                print("添加好友");
              },
              child: const Padding(
                padding: EdgeInsets.all(10),
                child: Icon(
                  Icons.person_add_alt,
                  color: Color(0xff1C1C1C),
                ),
              ))
        ],
      ),
      body: Column(
        children: [
          Container(
            color: const Color(0xffEDEDED),
            width: double.infinity,
            padding: const EdgeInsets.only(left: 8, right: 8, bottom: 10),
            child: InkWell(
              onTap: () {
                print("跳转搜索页");
              },
              child: Container(
                  padding: const EdgeInsets.symmetric(vertical: 6),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(4)),
                  child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Image.asset("assets/images/search.png",
                            width: 17, height: 17),
                        const SizedBox(width: 7),
                        const Text("搜索",
                            style: TextStyle(
                                color: Color(0xffB3B3B3), fontSize: 16))
                      ])),
            ),
          ),
          Expanded(
              child: ListView.builder(
            itemCount: defItems.length,
            itemBuilder: (context, i) => ListTile(
              title: Container(
                padding: const EdgeInsets.only(bottom: 10),
                decoration: const BoxDecoration(
                    border: Border(
                  bottom: BorderSide(width: 1, color: Color(0xffE5E5E5)),
                )),
                child: Text(defItems[i]["title"] ?? ""),
              ),
              leading: ClipRRect(
                borderRadius: BorderRadius.circular(5),
                child: Image.asset(defItems[i]["img"] ?? ""),
              ),
            ),
          ))
        ],
      ),
    );
  }
}
